﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KTDS_TELNET_CHECK
{
    public struct TelnetInfo
    {
        public string ip;
        public int port;
        public bool result;
    }

    public partial class UI_TELNET_CHECK : UserControl
    {
        public UI_TELNET_CHECK()
        {
            InitializeComponent();
        }

        private void btn_MultiPingCheck_Click(object sender, EventArgs e)
        {
            List<TelnetInfo> lst_telnetinfo = new List<TelnetInfo>();
            C_Telnet telnet = new C_Telnet();

            String[] FirstSplitText = txb_MultiIp_PortResult.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None);

            for (int i = 0; i < FirstSplitText.Length; i++)
            {
                TelnetInfo telnet_info = new TelnetInfo();
                String[] SecondSplitText = FirstSplitText[i].Split(',');

                telnet_info.ip = SecondSplitText[0].ToString();
                telnet_info.port = Convert.ToInt32(SecondSplitText[1]);
                telnet_info.result = telnet.CheckTheTelnet(telnet_info.ip, telnet_info.port);

                txb_MultiIp_PortResult.Text = telnet_info.ip + ",";
                txb_MultiIp_PortResult.Text += telnet_info.port + ",";
                txb_MultiIp_PortResult.Text += telnet_info.result.ToString() + Environment.NewLine;
            }
        }
    }
}
